import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/Layout';
import Home from '@/views/Home'
import Login from '@/views/Login';

Vue.use(VueRouter)

const routes = [
  {
    path: '',
    component: Layout,
    redirect: '/',
    // 路由元信息只要配置给父路由，下面的子路由也会被拦截。
    meta: {
      isLogin: true
    },
    children: [
      {
        path: '/',
        component: Home
      },
      {
        path: '/goods',
        component: () => import('@/views/Goods')
      },
      {
        path: '/params',
        component: () => import('@/views/Params'),
        redirect: '/params/rule',
        children: [
          {
            path: 'rule',
            component: () => import('@/views/Params/Rule')
          },
          {
            path: 'package',
            component: () => import('@/views/Params/Package')
          }
        ]
      },
      {
        path: '/order',
        component: () => import('@/views/Order')
      },
      {
        path: '/user',
        component: () => import('@/views/User')
      },
    ]
  },
  {
    path: '/login',
    component: Login
  }
]

const router = new VueRouter({
  routes
})

export default router
